package com.fastCms.business.bim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fastCms.business.frame.constant.CommonConst;
import com.fastCms.business.bim.pojo.entity.Pollution;
import com.fastCms.business.bim.daos.PollutionMapper;
import com.fastCms.business.bim.service.PollutionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 排放源表 服务实现类
 * </p>
 *
 * @author liusq
 * @since 2021-07-07
 */
@Service
public class PollutionServiceImpl extends ServiceImpl<PollutionMapper, Pollution> implements PollutionService {

    @Override
    public Pollution findById(String id) {
        QueryWrapper<Pollution> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        queryWrapper.eq("id", id);
        return getOne(queryWrapper);
    }

    @Override
    public int countByType(String type) {
        QueryWrapper<Pollution> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        queryWrapper.eq("pollution_type", type);
        return count(queryWrapper);
    }
}
